<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href='./css/styles.css' type="text/css" rel="stylesheet" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery-1.7.2.js"></script>
<script type="text/javascript">
	var checkSameAccountFlag=false;
	var checkPassword=false;
	function submit(){
		if(checkSameAccountFlag){
			alert("该账号存在");
			$("input[name='account']").focus();
			return ;
		}
		if(checkPassword){
			alert("密码不一致");
			$("input[name=passwordSame]").focus();
			return ;
		}
		
		$("#submit-register").submit();
	}
	$(function($) {
	});
	function checkSameAccount(){
		var account=$("input[name='account']").val();
		$.getJSON("user-checkSameAccount.action?account="+account+"&date="+new Date(),checkReplyData);
	}
	function checkReplyData(data) {
		$("#accountAlert").remove();
		checkSameAccountFlag=false;
		var accountVal=$("input[name='account']").val();
		if(data.value!="0"){
			checkSameAccountFlag=true;
			$("input[name='account']").after("<font id=\"accountAlert\" color=\"red\">&nbsp;&nbsp;用户名"+accountVal+"已存在</font>");
		}
	}
	function checkSamePassword(){
		var password1=$("input[name='password']").val();
		var password2=$("input[name='passwordSame']").val();
		if(password1==password2){
			checkPassword=false;
		}else{
			$("input[name='passwordSame']").after("<font id=\"passwordAlert\" color=\"red\">&nbsp;&nbsp;密码不一致</font>");
			checkPassword=true;
		}
	}
</script>
<title>Insert title here</title>
</head>
<body>
<s:debug></s:debug>
	<div class="divOuterFrame">
		<div class="divInnerFrame">注册页面</div>
	</div>
	<s:form action="user-save.action" theme="simple" name="submit-register" id="submit-register">
		<table>
			<tr>
				<td>账号： </td>
				<td><s:textfield name="account" onchange="checkSameAccount()" ></s:textfield></td>
			</tr>
			<tr>
				<td>密码：</td>
				<td><s:password name="password"></s:password></td>
			</tr>
			<tr>
				<td>重复输入密码：</td>
				<td><s:password name="passwordSame" onchange="checkSamePassword()" ></s:password></td>
			</tr>
			<tr>
				<td>姓名：</td>
				<td><s:textfield name="name"></s:textfield></td>
			</tr>
			<tr>
				<td>手机号：</td>
				<td><s:textfield name="phoneNumber"></s:textfield></td>
			</tr>
			<tr>
				<td>住址：</td>
				<td><s:textfield name="address"></s:textfield></td>
			</tr>
			<tr>
				<td>电子邮箱：</td>
				<td><s:textfield name="email"></s:textfield></td>
			</tr>
			<tr>
				<td>出生日期：</td>
				<td><s:textfield name="brithDay"></s:textfield></td>
			</tr>
			<tr>
				<td colspan="2"><s:a href="javascript:submit()">提交</s:a> </td>
			</tr>
		</table>
	</s:form>
</body>
</html>